package com.example.mrwang.myapplication;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import util.OrderRefundPopuWindow;

public class AniamationActivity extends AppCompatActivity {
    LinearLayout lin;
    RelativeLayout linBg;
    private OrderRefundPopuWindow window;
    String TAG = "POPWINDOW";
    View popView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_aniamation);

        linBg = (RelativeLayout) findViewById(R.id.rel_bg);
        lin = (LinearLayout) findViewById(R.id.lin_foot);
        popView = LayoutInflater.from(AniamationActivity.this).inflate(R.layout.popuwindow_order_refund, null);

        lin.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                RelativeLayout rel = (RelativeLayout) popView.findViewById(R.id.rel_child);
                ViewWrapper wrapper = new ViewWrapper(rel);
                ObjectAnimator scaleAnimHeight = ObjectAnimator.ofInt(wrapper, "height", 500);
                ObjectAnimator scaleAnimWidth = ObjectAnimator.ofInt(wrapper, "width", 500);
                AnimatorSet set = new AnimatorSet();
                set.setDuration(500);
                set.play(scaleAnimWidth).with(scaleAnimHeight);
                set.start();
            }
        });


    }

    private static class ViewWrapper {
        //代理对象
        private RelativeLayout mTarget;

        //        LinearLayout mLinFull;
        public ViewWrapper(RelativeLayout target) {
            mTarget = target;
        }

        public int getWidth() {
            return mTarget.getLayoutParams().width;
        }

        public int getHeight() {
            return mTarget.getLayoutParams().height;
        }

        public void setWidth(int width) {
            mTarget.getLayoutParams().width = width;
            mTarget.requestLayout();
        }

        public void setHeight(int height) {
            mTarget.getLayoutParams().height = height;
            mTarget.requestLayout();
        }

        public void setClearManager() {
            FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
            lp.setMargins(0, 0, 0, 0);
            mTarget.setLayoutParams(lp);
        }
    }

}
